package thread;

class Singleton{//饿汉模式的单例模式
    private static  Singleton instance = new Singleton();

    public static Singleton getInstance(){
        return instance;
    }
    //单例模式把构造方法改为private修饰
    private Singleton(){

    }

}
public class Demo20 {
    public static void main(String[] args) {
        Singleton t1 = Singleton.getInstance();
        Singleton t2 = Singleton.getInstance();
        System.out.println(t1==t2);

    }
}
